import apis from '../../http/apis/apis';
export default {
    // 避免命名冲突
    namespaced: true,
    state: {
        account: '',
        password: '',
        phone: ''
    },
    mutations: {
        changeLessLors(state, data) {
            state.account = data.account;
            state.password = data.password;
            state.phone = data.phone;
        }
    },
    actions: {

        //出租方的注册请求
        async lessorsRegister(context) {
            const {
                data
            } = await apis.lessors.lessorsRegister({
                account: context.state.account,
                password: context.state.password,
                telephone: context.state.phone
            });

            if (data.status) {
                console.log(data);
                alert("注册成功");
            }
        },

        //验证账号是否存在
        async isRegister(context) {
            const {
                data
            } = await apis.lessors.isRegister({
                account: context.state.account,
            });
            console.log(context.state.account);
            if (!data.status) {
                alert('用户名已存在，请重新输入');
            }
            return data.status;

        },
    }
}